home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch1 / ShowFont.frm (.txt) < prev    next >
Visual Basic Form  |  1999-08-08  |  4KB  |  151 lines

  1. VERSION 5.00
  2. Begin VB.Form frmShowForm 
  3.    Caption         =   "ShowFont"
  4.    ClientHeight    =   4020
  5.    ClientLeft      =   2115
  6.    ClientTop       =   1215
  7.    ClientWidth     =   6525
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   4020
  11.    ScaleWidth      =   6525
  12.    Begin VB.TextBox txtSize 
  13.       Height          =   285
  14.       Left            =   480
  15.       TabIndex        =   9
  16.       Text            =   "12.0"
  17.       Top             =   240
  18.       Width           =   855
  19.    End
  20.    Begin VB.CheckBox chkUnderline 
  21.       Caption         =   "Underline"
  22.       Height          =   375
  23.       Left            =   0
  24.       TabIndex        =   7
  25.       Top             =   1680
  26.       Width           =   1335
  27.    End
  28.    Begin VB.CheckBox chkStrikeThrough 
  29.       Caption         =   "StrikeThrough"
  30.       Height          =   375
  31.       Left            =   0
  32.       TabIndex        =   6
  33.       Top             =   1320
  34.       Width           =   1335
  35.    End
  36.    Begin VB.CheckBox chkItalic 
  37.       Caption         =   "Italic"
  38.       Height          =   375
  39.       Left            =   0
  40.       TabIndex        =   5
  41.       Top             =   960
  42.       Width           =   1335
  43.    End
  44.    Begin VB.CheckBox chkBold 
  45.       Caption         =   "Bold"
  46.       Height          =   375
  47.       Left            =   0
  48.       TabIndex        =   4
  49.       Top             =   600
  50.       Width           =   1335
  51.    End
  52.    Begin VB.TextBox txtSample 
  53.       Height          =   3735
  54.       Left            =   3720
  55.       Locked          =   -1  'True
  56.       MultiLine       =   -1  'True
  57.       ScrollBars      =   3  'Both
  58.       TabIndex        =   3
  59.       Top             =   240
  60.       Width           =   2775
  61.    End
  62.    Begin VB.ListBox lstScreenFonts 
  63.       Height          =   3765
  64.       Left            =   1440
  65.       Sorted          =   -1  'True
  66.       TabIndex        =   0
  67.       Top             =   240
  68.       Width           =   2175
  69.    End
  70.    Begin VB.Label Label2 
  71.       Caption         =   "Size"
  72.       Height          =   255
  73.       Left            =   0
  74.       TabIndex        =   8
  75.       Top             =   240
  76.       Width           =   375
  77.    End
  78.    Begin VB.Label Label1 
  79.       Alignment       =   2  'Center
  80.       Caption         =   "Sample"
  81.       Height          =   255
  82.       Index           =   1
  83.       Left            =   3720
  84.       TabIndex        =   2
  85.       Top             =   0
  86.       Width           =   2775
  87.    End
  88.    Begin VB.Label Label1 
  89.       Alignment       =   2  'Center
  90.       Caption         =   "Fonts"
  91.       Height          =   255
  92.       Index           =   0
  93.       Left            =   1440
  94.       TabIndex        =   1
  95.       Top             =   0
  96.       Width           =   2175
  97.    End
  98. Attribute VB_Name = "frmShowForm"
  99. Attribute VB_GlobalNameSpace = False
  100. Attribute VB_Creatable = False
  101. Attribute VB_PredeclaredId = True
  102. Attribute VB_Exposed = False
  103. Option Explicit
  104. ' Change the sample text's font.
  105. Private Sub ShowSample()
  106.     With txtSample.Font
  107.         .Name = lstScreenFonts.List(lstScreenFonts.ListIndex)
  108.         .Bold = (chkBold.Value = vbChecked)
  109.         .Italic = (chkItalic.Value = vbChecked)
  110.         .Strikethrough = (chkStrikeThrough.Value = vbChecked)
  111.         .Underline = (chkUnderline.Value = vbChecked)
  112.         .Size = CSng(txtSize.Text)
  113.     End With
  114. End Sub
  115. Private Sub chkBold_Click()
  116.     ShowSample
  117. End Sub
  118. Private Sub chkItalic_Click()
  119.     ShowSample
  120. End Sub
  121. Private Sub chkStrikeThrough_Click()
  122.     ShowSample
  123. End Sub
  124. Private Sub chkUnderline_Click()
  125.     ShowSample
  126. End Sub
  127. Private Sub Form_Load()
  128. Dim i As Integer
  129.     ' Fill the font list with font names.
  130.     For i = 0 To Screen.FontCount - 1
  131.         lstScreenFonts.AddItem Screen.Fonts(i)
  132.     Next i
  133.     lstScreenFonts.ListIndex = 0
  134.     lstScreenFonts.Selected(0) = True
  135.     ' Fill in the sample text.
  136.     txtSample.Text = "ABCDE" & vbCrLf & _
  137.         "FGHIJ" & vbCrLf & "KLMNO" & vbCrLf & _
  138.         "PQRST" & vbCrLf & "UVWXYZ" & vbCrLf & _
  139.         "abcde" & vbCrLf & "fghij" & vbCrLf & _
  140.         "klmno" & vbCrLf & "pqrst" & vbCrLf & _
  141.         "uvwxyz" & vbCrLf & "12345" & vbCrLf & _
  142.         "67890"
  143. End Sub
  144. ' Change the sample label's font.
  145. Private Sub lstScreenFonts_Click()
  146.     ShowSample
  147. End Sub
  148. Private Sub txtSize_Change()
  149.     If IsNumeric(txtSize.Text) Then ShowSample
  150. End Sub
  151.